{% extends 'base' %}

{% block title %}
创建
{% endblock %}

{% import 'form' as form %}

{% if ser_instance is undefined %}
    {% set ser_instance = {'name':'', 'ip':'', 'description':'', 'date':''} %}
    {% set active_page = "server_add" %}
    {% set legend = True %}
{% endif %}

{% block content %}

<div>

<ul class="breadcrumb">
    <li><a href="/">网站后台</a><span class="divider">/</span></li>
    <li><a href="/server/list">服务器</a><span class="divider">/</span></li>
    <li class="active">添加服务器<span class="divider">/</span></li>
</ul>

    <form action="" method="POST">
        <fieldset>
            {% if legend %}
            <legend>添加服务器</legend>
            {% else %}
            <legend>修改服务器[{{ ser_instance.name }}]</legend>
            {% endif %}
            {{ form.input(name='name', label='服务器名', value=ser_instance.name) }}
            {{ form.input(name='ip', label='IP:PORT', help_text="<b class='text-info'>XMLRPCServer的IP和端口, eg: 127.0.0.1:8080.</b>",
                value=ser_instance.ip|default('')) }}
            {{ form.textarea(name='description', label='描述', placeholder='必要信息',
                value=ser_instance.description|default('')) }}
            {{ form.input(name='date', label='购进日期', help_text="购进日期，格式随意。",
                value=ser_instance.date|default('')) }}
            {{ form.select(name='location', label='所在机房', help_text='所在机房', options=locations,
                default=ser_instance.location_ID) }}
        </fieldset>
            {{ form.submit(value="提交") }}
    </form>
</div>

{% endblock %}